<template>
 <div>
   <div class="bgfff mtrbl20 ptrbl20 nopb20">
    <el-row :gutter="20">
      <!--用户数据-->
      <el-col :span="24" :xs="24">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item prop="month">
            <el-date-picker
            v-model="queryParams.month"
            value-format="yyyyMM"
            type="month"
            placeholder="请选择月份">
            </el-date-picker>
        </el-form-item>
        <el-form-item prop="invoiceStatus">
            <el-select
              v-model="queryParams.invoiceStatus"
              placeholder="开票状态"
              clearable
            >
              <el-option label="未开票" value="0"></el-option>
              <el-option label="部分未开票" value="2"></el-option>
              <el-option label="已开票" value="3"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="medium" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
        </el-form-item>
        </el-form>
        </el-col>
      </el-row>
  </div>      
  <div class="app-container">
    <el-row :gutter="20">
      <!--用户数据-->
      <el-col :span="24" :xs="24">
        <el-table v-loading="loading" :data="invoiceBatchList">
          <el-table-column fixed label="序号" prop="" width="55" align="center">
            <template slot-scope="scope">
              <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="批次号" align="left" key="batchNo" prop="batchNo" width="300"/>
          <el-table-column label="应开金额" align="left" key="totalMoney" prop="totalMoney"/>
          <el-table-column label="总条数" align="left" key="totalNumber" prop="totalNumber"/>
          <el-table-column label="开票状态" align="left" key="invoiceStatus.name" prop="invoiceStatus.name" />
          <el-table-column label="开票周期" align="left" key="taxDate" prop="taxDate" />
          <el-table-column label="创建时间" align="left" key="createTime" prop="createTime"/>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleView(scope.row)"
            >详情</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
  </div>
</div>
</template>

<script>
import { invoiceBatchList } from "@/api/taxmsg/invoice";
import { getToken } from "@/utils/auth";
export default {
  name: "Invoice",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 显示搜索条件
      showSearch: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 用户表格数据
      invoiceBatchList: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        month: undefined,
        invoiceStatus: undefined,
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      if(this.queryParams.invoiceStatus==""){
        this.queryParams.invoiceStatus = null
      }
      invoiceBatchList(this.queryParams).then(response => {
          this.invoiceBatchList = response.data.list;
          this.total = response.data.total;
          this.loading = false;
        }
      ).catch(()=>{});
    },
    /** 修改按钮操作 */
    handleView(row) {
      const id = row.id;
      this.$router.push("/invoice/details/" + id);
    },
    /** 搜索按钮操作 */
    handleQuery() {
        this.queryParams.page = 1;
        this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
<style scoped lang="scss">
</style>